﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CamShared;

namespace CamServer
{
    public partial class CameraProperties : DavuxLib.Controls.AeroForm
    {
        private ICamera camera = null;

        DavuxLib.SettingsUI sui = new DavuxLib.SettingsUI();

        public CameraProperties(ICamera camera)
        {
            this.camera = camera;
            InitializeComponent();

            this.Text = camera.Name + " Properties";
            _GlassArea.Bottom = ClientRectangle.Height - btnApply.Location.Y + 2;

            sui.OnSettingFound += new DavuxLib.SettingsUI.SettingStringFound(sui_OnSettingFound);
            sui.LoadControlData(Controls);
        }

        string sui_OnSettingFound(string settingString)
        {
            return settingString.Replace("%", camera.Name);
        }


        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            Invalidate();
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            sui.SaveControlData(Controls);
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btndv_Click(object sender, EventArgs e)
        {
            camera.ShowConfig(this.Handle);
        }
    }
}
